import {createPinia,defineStore,StoreDefinition} from 'pinia'
import  piniaPlugin from 'pinia-plugin-persist'

let store=createPinia()
//使用持久化插件
store.use(piniaPlugin)
export type navList ={
    path:string;
    name?:string;
}
let useNav:StoreDefinition=defineStore('routerList',{
    state:()=>{
        return {
           nav:['nnnn'],
           num:0
        }
    },
    getters:{
        navLen(){
           return this.nav.length
        }
    },
    actions:{
        navput(nav:string){
            //直接用this获取state中的数据
            this.nav.push(nav)
        }
    },
    persist:{
        enabled: true,
        strategies:[{
            key: 'num',
            storage: localStorage,
            paths: ['num'],
        }]
    }
     
})

export {store,useNav} 